/**
 * 
 */
package arisufascion.com.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import arisufascion.com.R;
import arisufascion.com.constant.Constants;
import arisufascion.com.model.Attribute;

import com.androidquery.AQuery;

/**
 * @author Kelvin
 *
 */
public class GalleryImageColorAdapter extends BaseAdapter{
	private Context mContext;
	private List<Attribute> attributes;
	private AQuery aq;


    public GalleryImageColorAdapter(Context context, List<Attribute> attributes) 
    {
        mContext = context;
        this.attributes=attributes;
        aq = new AQuery(context);
    }

    public int getCount() {
        return attributes.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }


    // Override this method according to your need
    public View getView(int index, View view, ViewGroup viewGroup) 
    {
        // TODO Auto-generated method stub
        ImageView i = new ImageView(mContext);

        String url = String.format(Constants.SERVER_URL_IMAGES,
				String.valueOf(attributes.get(index).getPhoto()));

		aq.id(i).image(url, true, true, 0, R.drawable.icon_logo);
		
        i.setLayoutParams(new Gallery.LayoutParams(150,150));
    
        i.setScaleType(ImageView.ScaleType.FIT_XY);

        return i;
    }
}
